class Solution:
    def removeElement(self, nums: list[int], val: int) -> int:
        flag = 0
        for i in range(len(nums)):
            if nums[i] != val:
                nums[flag] = nums[i]
                flag += 1
        return flag


def PrintNum(n, cnt):
    print(n[:cnt])

if __name__ == '__main__':
    s = Solution()
    n = [3,2,2,3]
    PrintNum(n, s.removeElement(n, 3))
    n = [0,1,2,2,3,0,4,2]
    PrintNum(n, s.removeElement(n, 2))